package shaw.wifi.server;

import java.io.IOException;
import java.net.ServerSocket;

public class NetworkSettingsServer {
	private ServerSocket serverSocket;
	private ClientConnectionManager connectionManager;
	
	public void runServer(int port, int backlog) {
		connectionManager = new ClientConnectionManager();
		
		try {
			serverSocket = new ServerSocket(port, backlog);
			System.out.println("Running on port " + port);
			while(true) {
				ClientConnection con = new ClientConnection(serverSocket.accept(), connectionManager);
				Thread t = new Thread(con);
				t.start();
				System.out.println("Client connection established...");
			}
		} catch (IOException e) {
			e.printStackTrace();
		}
	}
}
